//
//  UIView+GradientView.m
//  lifestyle
//
//  Created by wd on 15/8/3.
//  Copyright (c) 2015年 Wei Chuang Le ,Ltd. All rights reserved.
//

#import "UIView+GradientView.h"

@implementation UIView (GradientView)
+ (UIView *)setGradientColorView:(CGRect)frame fromColor:(UIColor *)fromColor toColor:(UIColor *)toColor
{
    UIView *view = [[UIView alloc]initWithFrame:frame];
    CAGradientLayer *colorLayer = [CAGradientLayer layer];
    colorLayer.frame = view.bounds;
    [view.layer addSublayer:colorLayer];
    
    // 颜色分配
    colorLayer.colors = @[(__bridge id)fromColor.CGColor,
                          (__bridge id)toColor.CGColor,
                          ];
    
    // 起始点
    colorLayer.startPoint = CGPointMake(0,1);
    
    // 结束点
    colorLayer.endPoint   = CGPointMake(1,1);
    
    return view;
}
@end
